package com.example.practice2023.controller;


import com.example.practice2023.pojo.Member;
import com.example.practice2023.service.MemberService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/member")
public class MemberController {

    @Resource
    private MemberService memberService;

    @RequestMapping(value = "/selectBymemberId",method = RequestMethod.GET)
    public Map<String,Object> selectBymemberId(@RequestParam Integer memberId){
        return memberService.selectBymemberId(memberId);
    }

    @RequestMapping(value = "/insertMember",method = RequestMethod.POST)
    public Map<String,Object> insertMember(@RequestBody Member member){
        return memberService.insertMember(member);
    }

    @RequestMapping(value = "/updateBymemberId",method = RequestMethod.POST)
    public Map<String,Object> updateBymemberId(@RequestBody Member member){
        return memberService.updateBymemberId(member);
    }

    @RequestMapping(value = "/deleteBymemberId",method = RequestMethod.POST)
    public Map<String,Object> deleteBymemberId(Integer memberId){
        return memberService.deleteBymemberId(memberId);
    }

    @RequestMapping(value = "/selectMemberByPage",method = RequestMethod.GET)
    public Map<String, Object> selectMemberByPage(int page, int limit, Member member) {
        return memberService.selectMemberByPage(page, limit,member);
    }

    @RequestMapping(value = "/updateSwitch",method = RequestMethod.POST)
    public Map<String,Object> updateSwitch(@RequestBody Member member){
        return memberService.updateSwitch(member);
    }
}
